<?php
/**
 *  作者：梦雨
 *  @ QQ50361804
 */
namespace app\admin\controller;
use think\Controller;
use think\Db;
class Index extends Common
{
    public function index()
    {
    	
    	 return view();

    }
    public function home()
    {
    	//检查是否支持伪静态自动转换
        $path = 'app/extra/web.php';
        $file = (include $path);
        if(file_get_contents(http().$_SERVER['HTTP_HOST'].'/index/index/testing.html')==1){
        	$c =1;
        }else{
        	$c =0;
        }
        $config = array( 'WEIJINGTAI' => $c);
        $config = preg_replace("/[?><?'=]/", '', $config);
        $res = array_merge($file, $config);
        $str = '<?php return [';
        foreach ($res as $key => $value) {
            $str .= '\'' . $key . '\'' . '=>' . '\'' . $value . '\'' . ',';
        }
        $str .= ']; ';
        if (file_put_contents($path, $str)) {
            array_map('unlink', glob(TEMP_PATH . '/*.php'));
            rmdir(TEMP_PATH);xhw();
        }  
    	 return view();
    }
    public function sj()
    { 
    	$xiazai = $_POST['title'];
    	if (strpos($xiazai, pa('OMKRoa0sjP08YbU8kP1NyAXCkM2n2LaLgfGA9')) !== false) {
            $url = $xiazai . urlencode(iconv("GB2312", "UTF-8", ""));
            $save_dir = 'runtime/';
            $filename = 'shengji.zip';
            $res = getFile($url, $save_dir, $filename, 0);
            return json(array('code' => 200, 'msg' => '升级成功'));
    	} else {
            return json(array('code' => 0, 'msg' => '请复制官方的升级链接'));
        }
    }
    //解压
    public function ad()
    {
            $zip = new \ZipArchive();
            if ($zip->open('runtime/shengji.zip') === TRUE) {
                $zip->extractTo('.');
                $zip->close();
                unlink('runtime/shengji.zip');
                header("content-type:text/html;charset=utf-8");
                header('location:/admin.php/index/home.html');
            }

    }
}